#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import threading
import time

number = 0
lock = threading.Lock()


def plus(lk):
    global number
    lk.acquire()
    for _ in range(1000000):
        number += _
    print("子线程结束, 结果为: {}".format(number))
    lk.release()


if __name__ == '__main__':
    for i in range(2):
        t = threading.Thread(target=plus, args=(lock,))
        t.start()
    time.sleep(2)
    print("主线程结束....")
